<?php
	class mysqlClass
	{
		var $host,$user,$pwd,$db,$conn;
		var $result,$row,$data;
		public function __construct($host = DBHOST,$user = DBUSER,$pwd = DBPWD,$db = DBNAME)
		{
			$this->host = $host;
			$this->user = $user;
			$this->pwd = $pwd;
			$this->db = $db;
			$this->connect();
			mysql_query("SET NAMES UTF8;");
		}
		
		public function connect()
		{
			$this->conn = @mysql_connect($this->host,$this->user,$this->pwd) or die("数据库错误: ".mysql_error());
			$this->selectDb(); 
		}
		
		public function selectDb()
		{
			@mysql_select_db($this->db) or die("数据库错误: ".mysql_error());
		}
		
		public function query($query)
		{
			$this->result = mysql_query($query) or mysql_error();
			$this->row = @mysql_num_rows($this->result);
			return $this->result;
		}
		public function fetch($row = 0)
		{
		    @mysql_data_seek($this->result, $row) or mysql_error();
        	$this->data = mysql_fetch_array($this->result) or mysql_error();
    	}
	}
?>